package com.backstage.service.impl;

import com.backstage.common.page.Page;
import com.backstage.dao.FileDao;
import com.backstage.entity.File;
import com.backstage.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @TODO
 * @Author:阮雪峰
 * @Date：2017/8/6 20:52
 * @pagekage: com.backstage.service.impl
 * @project: authority
 */
@Service("fileService")
public class FileServiceImpl implements FileService {

    @Autowired
    private FileDao fileDao;

    @Override
    public void add(List<File> fileList) {
        fileDao.addBatch(fileList);
    }

    @Override
    public void delete(ArrayList<File> files) {
        for (File file : files) {

        }
        fileDao.deleteBach(files);
    }

    @Override
    public void queryByPage(Page<File> page, File file) {
        int totalCol = fileDao.getTotalColumn(page, file);
        List<File> list = fileDao.getList(page, file);

        page.setTotal(totalCol);
        page.setRows(list);
    }
}
